package main.java.br.com.projeto.domain.dao;

import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import main.java.br.com.projeto.domain.entity.Agendamento;

public class DaoAgendamento extends Dao<Agendamento> {

	public DaoAgendamento() {
		super(Agendamento.class);
	}
	

	public List<Agendamento> listByData(Calendar data) {
		String hql = "select Agendamento from Agendamento agendamento "
				+ "where agendamento.data = :data";

		Map<String, Object> parameters = new HashMap<String, Object>();
		parameters.put("data", data);


		return this.findOneResult(hql, parameters);
	}
	
	public List<Agendamento> listByServicoIdAndData(Long servicoId, Calendar data) {
		String hql = "select Agendamento from Agendamento agendamento "
				+ "where agendamento.servico.id = :servicoId "
				+ "and agendamento.data = :data";

		Map<String, Object> parameters = new HashMap<String, Object>();
		parameters.put("servicoId", servicoId);
		parameters.put("data", data);


		return this.findOneResult(hql, parameters);
	}
	
	public List<Agendamento> listByFuncionarioIdAndData(Long funcionarioId, Calendar data) {
		String hql = "select Agendamento from Agendamento agendamento "
				+ "where agendamento.funcionario.id = :funcionarioId "
				+ "and agendamento.data = :data";

		Map<String, Object> parameters = new HashMap<String, Object>();
		parameters.put("funcionarioId", funcionarioId);
		parameters.put("data", data);


		return this.findOneResult(hql, parameters);
	}
	
	public List<Agendamento> listByClienteIdAndData(Long clienteId, Calendar data) {
		String hql = "select Agendamento from Agendamento agendamento "
				+ "where agendamento.cliente.id = :clienteId "
				+ "and agendamento.data = :data";

		Map<String, Object> parameters = new HashMap<String, Object>();
		parameters.put("clienteId", clienteId);
		parameters.put("data", data);


		return this.findOneResult(hql, parameters);
	}
	
	public List<Agendamento> listByClienteId( Long clienteId )
	{
		String hql = "select Agendamento from Agendamento servicoOS "
				+ "where agendamento.cliente.id = :clienteId ";

		Map<String, Object> parameters = new HashMap<String, Object>();
		parameters.put("clienteId", clienteId);


		return this.findOneResult(hql, parameters);
	}
}
